package controller;

import service.TableService;
import util.JsonUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/table/delete")
public class TableDeleteController extends HttpServlet {
    private TableService ts = new TableService();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取需要删除的数据的ID
        String id = req.getParameter("id");
        //执行删除
        int d = ts.delete(id);
        if (d != 0){
            JsonUtils.jsonWrite(resp,"删除成功，不可恢复");
        }else{
            JsonUtils.jsonWrite(resp,"删除失败，请重新尝试删除");
        }
    }
}
